<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <title>综合数据监控平台</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">
    <!-- Le styles -->
    <script type="text/javascript" src="assets/js/jquery.js"></script>

    <link rel="stylesheet" href="assets/css/style.css">
    <link rel="stylesheet" href="assets/css/loader-style.css">
    <link rel="stylesheet" href="assets/css/bootstrap.css">

    <!-- 树形列表 -->
    <link rel="stylesheet" href="assets/js/tree/jquery.treeview.css">

    <link rel="stylesheet" href="assets/js/tree/treetable/stylesheets/jquery.treetable.css">
    <link rel="stylesheet" href="assets/js/tree/treetable/stylesheets/jquery.treetable.theme.default.css">
    <link href="assets/js/tree/tabelizer/tabelizer.min.css" media="all" rel="stylesheet" type="text/css">
    <!-- jqGrid -->
    <script type="text/ecmascript" src="assets/js/jqGrid/js/i18n/grid.locale-cn.js"></script>
    <script type="text/ecmascript" src="assets/js/jqGrid/src/jquery.jqGrid.js"></script>
    <link rel="stylesheet" type="text/css" media="screen" href="assets/js/jqGrid/css/ui.jqgrid-bootstrap.css" />
    <script>
        $.jgrid.defaults.width = 1000;
        $.jgrid.defaults.responsive = true;
        $.jgrid.defaults.styleUI = 'Bootstrap';
    </script>

    <link rel="stylesheet" type="text/css" href="assets/css/myCss.css">
    <link href="assets/js/treeview/css/bootstrap-treeview.css" rel="stylesheet">

    <!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
    <!--[if lt IE 9]>
        <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
        <![endif]-->
    <!-- Fav and touch icons -->
    <link rel="shortcut icon" href="assets/ico/favicon.ico">
    <style>
        /*模态框*/
        .modal-body-top {
            padding-bottom: 5px;
            border-bottom: 2px dotted #aaa;
            margin-bottom: 10px;
        }
        .modal {
            color:#777;
        }
        .modal .col-md-6{
            margin-bottom: 5px;
        }
        .modal input[type="date"], .modal input[type="file"], .modal select, .modal input[type="text"], .modal input[type="password"], .modal input[type="email"], .modal input[type="tel"] {
            line-height: 20px;
            width:260px;
            height:24px;
        }
        .modal input[type="file"] {
            display: inline-block;
        }
        /*#userRightModal .modal-body{
            height:300px;
            overflow-y: auto;
        }*/
    </style>
</head>

<body>
    <!-- Preloader -->
    <div id="preloader">
        <div id="status">&nbsp;</div>
    </div>
    <!-- TOP NAVBAR -->
    <nav role="navigation" class="navbar navbar-static-top">
        <div class="container-fluid">
            <!-- Brand and toggle get grouped for better mobile display -->
            <div class="navbar-header">
                <button data-target="#bs-example-navbar-collapse-1" data-toggle="collapse" class="navbar-toggle" type="button">
                    <span class="entypo-menu"></span>
                </button>
                <button class="navbar-toggle toggle-menu-mobile toggle-left" type="button">
                    <span class="entypo-list-add"></span>
                </button>

                <div id="logo-mobile" class="visible-xs">
                   <h1>综合数据监控平台<span>v1.0</span></h1>
                </div>

            </div>


            <!-- Collect the nav links, forms, and other content for toggling -->
            <div id="bs-example-navbar-collapse-1" class="collapse navbar-collapse">
                <ul class="nav navbar-nav">
                    <!-- 帮助 -->
                    <li><a href="#"><i data-toggle="tooltip" data-placement="bottom" title="Help" style="font-size:20px;" class="icon-help tooltitle"></i></a>
                    </li>

                </ul>
                <!-- 时间天气框 -->
                <div id="nt-title-container" class="navbar-left running-text visible-lg">
                    <ul class="date-top">
                        <li class="entypo-calendar" style="margin-right:5px"></li>
                        <li id="Date"></li>
                    </ul>

                    <ul id="digital-clock" class="digital">
                        <li class="entypo-clock" style="margin-right:5px"></li>
                        <li class="meridiem"></li>
                        <li class="hour"></li>
                        <li>:</li>
                        <li class="min"></li>
                        <li>:</li>
                        <li class="sec"></li>
                    </ul>
                    <ul id="nt-title">
                        <li><i class="wi-day-lightning"></i>&#160;&#160;西安&#160;
                            <b>85</b><i class="wi-fahrenheit"></i>&#160; 
                        </li>
                        <li><i class="wi-day-lightning"></i>&#160;&#160;西安 &#160;
                            <b>70</b><i class="wi-fahrenheit"></i>&#160;; 夜晚- 72 °F (22.2 °C)
                        </li>

                        <li><i class="wi-day-lightning"></i>&#160;&#160;咸阳&#160;
                            <b>65</b><i class="wi-fahrenheit"></i>&#160;
                        </li>

                        <li><i class="wi-day-lightning"></i>&#160;&#160;渭南&#160;
                            <b>80</b><i class="wi-fahrenheit"></i>&#160;
                        </li>

                        <li><i class="wi-day-lightning"></i>&#160;&#160;汉中&#160;
                            <b>55</b><i class="wi-fahrenheit"></i>&#160;
                        </li>

                    </ul>
                </div>

                <ul style="margin-right:0;" class="nav navbar-nav navbar-right">
                    <li>
                        <a data-toggle="dropdown" class="dropdown-toggle" href="#">
                            <img alt="" class="admin-pic img-circle" src="assets/img/portraits/10.jpg">你好, 田七 <b class="caret"></b>
                        </a>
                        <ul style="margin-top:14px;" role="menu" class="dropdown-setting dropdown-menu">
                            <li>
                                <a href="profile.html">
                                    <span class="entypo-user"></span>&#160;&#160;头像</a>
                            </li>
                            <li>
                                <a href="#">
                                    <span class="entypo-vcard"></span>&#160;&#160;设置</a>
                            </li>
                            <li class="divider"></li>
                            <li>
                                <a href="login.html?b=1">
                                    <span class="entypo-logout"></span>&#160;&#160; 退出登录</a>
                            </li>
                        </ul>
                    </li>
                    <li>
                        <a data-toggle="dropdown" class="dropdown-toggle" href="#">
                            <span class="icon-gear"></span>&#160;&#160;主题</a>
                        <ul role="menu" class="dropdown-setting dropdown-menu">

                            <li class="theme-bg">
                                <div id="button-bg"></div>
                                <div id="button-bg2"></div>
                                <div id="button-bg3"></div>
                                <div id="button-bg5"></div>
                                <div id="button-bg6"></div>
                                <div id="button-bg7"></div>
                                <div id="button-bg8"></div>
                                <div id="button-bg9"></div>
                                <div id="button-bg10"></div>
                                <div id="button-bg11"></div>
                                <div id="button-bg12"></div>
                                <div id="button-bg13"></div>
                            </li>
                        </ul>
                    </li>
                </ul>

            </div>
            <!-- /.navbar-collapse -->
        </div>
        <!-- /.container-fluid -->
    </nav>

    <!-- /END OF TOP NAVBAR -->

    <!-- SIDE MENU -->
    <div id="skin-select">
        <div id="logo">
            <img src="assets/img/logo.png" alt="大连睿科电子有限公司">
        </div>

        <a id="toggle">
            <span class="entypo-menu"></span>
        </a>


        <div class="skin-part">
            <div id="tree-wrap">
                <div class="side-bar">
                    <ul class="topnav menu-left-nest">
                        <li>
                            <a class="tooltip-tip ajax-load" href="index.html" title="首页">
                                <i class="icon-home"></i>
                                <span>首页</span>

                            </a>
                        </li>
                    </ul>

                    <ul class="topnav menu-left-nest">
                        <li>
                            <a href="#" style="border-left:0px solid!important;" class="title-menu-left">

                                <span class="widget-menu"></span>
                                <i data-toggle="tooltip" class="entypo-cog pull-right config-wrap"></i>

                            </a>
                        </li>

                        <li>
                            <a class="tooltip-tip ajax-load" href="realtime-data.html" title="实时数据">
                                <i class="icon-document-edit"></i>
                                <span>实时数据</span>

                            </a>
                        </li>
                        <li>
                            <a class="tooltip-tip ajax-load" href="chart-data.html" title="数据曲线">
                                <i class="icon-graph-line"></i>
                                <span>数据曲线</span>

                            </a>
                        </li>
                        <li>
                            <a class="tooltip-tip ajax-load" href="history-data.html" title="历史数据">
                                <i class="icon-document"></i>
                                <span>历史数据</span>

                            </a>
                        </li>
                    </ul>

                    <ul class="topnav menu-left-nest">
                        <li>
                            <a href="#" style="border-left:0px solid!important;" class="title-menu-left">

                                <span class="design-kit"></span>
                                <i data-toggle="tooltip" class="entypo-cog pull-right config-wrap"></i>

                            </a>
                        </li>

                        <li>
                            <a class="tooltip-tip ajax-load" href="device-manage.html" title="设备管理">
                                <i class="icon-view-thumb"></i>
                                <span>设备管理</span>

                            </a>
                        </li>
                        <li>
                            <a class="tooltip-tip ajax-load" href="user-manage.html" title="用户管理">
                                <i class="icon-user"></i>
                                <span>用户管理</span>

                            </a>
                        </li>
                        <li>
                            <a class="tooltip-tip ajax-load" href="login-record.html" title="登录日志">
                                <i class="icon-user-group"></i>
                                <span>登录日志</span>

                            </a>
                        </li>
                        <!-- <li>
                            <a class="tooltip-tip ajax-load" href="SIMinfo-manage.html" title="SIM卡信息管理">
                                <i class="icon-message"></i>
                                <span>SIM卡信息管理</span>

                            </a>
                        </li>
                        <li>
                            <a class="tooltip-tip ajax-load" href="#" title="系统设置">
                                <i class="icon-gear"></i>
                                <span>系统设置</span>

                            </a>
                        </li> -->
                    </ul>

                    <ul class="topnav menu-left-nest">
                        <li>
                            <a href="#" style="border-left:0px solid!important;" class="title-menu-left">

                                <span class="component"></span>
                                <i data-toggle="tooltip" class="entypo-cog pull-right config-wrap"></i>

                            </a>
                        </li>

                        <li>
                            <a class="tooltip-tip" href="warning-handle.html" title="报警处理">
                                <i class="icon-warning"></i>
                                <span>报警处理</span>
                            </a>
                        </li>
                        <li>
                            <a class="tooltip-tip" href="warning-config.html" title="报警设置">
                                <i class="icon-attachment"></i>
                                <span>报警设置</span>
                            </a>
                        </li>

                    </ul>


                </div>
            </div>
        </div>
    </div>
    <!-- END OF SIDE MENU -->



    <!--  PAPER WRAP -->
    <div class="wrap-fluid">
        <div class="container-fluid paper-wrap bevel tlbr">





            <!-- CONTENT -->
            <!--TITLE -->
            <div class="row">
                <div id="paper-top">
                    <div class="col-sm-3">
                        <h2 class="tittle-content-header">
                            <i class="icon-document"></i> 
                            <span>用户管理
                            </span>
                        </h2>

                    </div>

                    <div class="col-sm-7">
                        <div class="devider-vertical visible-lg"></div>
                        <div class="tittle-middle-header">

                            <div class="alert">
                                <button type="button" class="close" data-dismiss="alert">×</button>
                                <span class="tittle-alert entypo-info-circled"></span>
                                欢迎回来,&nbsp;
                                <strong>田七 !</strong>&nbsp;&nbsp;您上次登录是 昨天下午 16:54 
                            </div>


                        </div>

                    </div>
                </div>
            </div>
            <!--/ TITLE -->

            <!-- BREADCRUMB -->
            <ul id="breadcrumb">
                <li>
                    <span class="entypo-home"></span>
                </li>
                <li><i class="fa fa-lg fa-angle-right"></i>
                </li>
                <li><a href="#">系统管理</a>
                </li>
                <li><i class="fa fa-lg fa-angle-right"></i>
                </li>
                <li><a href="user-manage.html">用户管理</a>
                </li>
                <li class="pull-right">
                    <div class="input-group input-widget">
                        <input style="border-radius:15px" type="text" placeholder="搜索..." class="form-control">
                    </div>
                </li>
            </ul>

            <!-- END OF BREADCRUMB -->



            <div class="content-wrap">
                <div class="row">


                    <div class="col-sm-12">

                        <div class="nest" id="FootableClose">
                            <div class="title-alt">
                                <h6>
                                    用户列表
                                </h6>
                                <div class="top">
                                    <div class="form-group">
                                        
                                        <!-- <a href="#" class="btn btn-inverse" data-toggle="modal" data-target="#userRoleModal"><span class="entypo-attach"></span> 绑定角色</a> -->
                                        <a href="#" class="btn btn-inverse" data-toggle="modal" data-target="#userRightModal" id="a"><span class="entypo-link"></span> 绑定权限</a>
                                        <!-- <a href="#" class="btn btn-inverse" data-toggle="modal" data-target="#resetPwdModal"><span class="entypo-lock-open"></span> 重置密码</a> -->
                                        
                                    </div>
                                </div>
                                

                            </div>

                            <div class="body-nest" id="Footable">
                                <div style="clear:both;"></div>
                                <div class="row dataContent">
                                    <div class="col-xs-12 col-sm-12 col-md-2 form-group">
                                        <input type="checkbox" id="autosearch" onclick="enableAutosubmit(this.checked)"> 是否自动查询
                                    </div>
                                    <div class="col-xs-12 col-md-10 form-group">
                                        <label for="s_account">账号:</label>
                                        <input type="text" id="s_account" onkeydown="doSearch(arguments[0]||event)" />
                                        <label for="s_name">用户名:</label>
                                        <input type="text" id="s_name" onkeydown="doSearch(arguments[0]||event)" />
                                        <label for="s_clientname">客户名称:</label>
                                        <input type="text" id="s_clientname" onkeydown="doSearch(arguments[0]||event)" />
                                        <button class="btn btn-primary" onclick="gridReload()" id="submitButton" style="margin-left:30px;"><span class="entypo-search"></span> 查询</button>
                                        <input type="button" class="btn btn-success" value="导出EXCEL" >
                                    </div>
                                </div>

                                <table id="jqGrid"></table>
                                <div id="jqGridPager"></div>
                            </div>

                        </div>


                    </div>

                </div>
            </div>


            <!-- /END OF CONTENT -->



            <!-- FOOTER -->
            <!-- <div class="footer-space"></div> -->
            <div id="footer">
                <div class="devider-footer-left"></div>
                <div class="time">
                    <p id="spanDate">
                    <p id="clock">
                </div>
                <div class="copyright">
                        版权归 <a href="http://www.brjzbs.com/" title="西安天通物联网科技有限公司" target="_blank">西安天通物联网科技有限公司</a> 所有
                </div>
                <div class="devider-footer"></div>
            </div>
            <!-- / END OF FOOTER -->


        </div>
    </div>
    <!--  END OF PAPER WRAP -->

    <!-- 4. 账户绑定角色模态框 -->
    <!-- <div class="modal fade bs-example-modal-lg" id="userRoleModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
      <div class="modal-dialog modal-lg" role="document">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
            <h4 class="modal-title" id="myModalLabel">账户绑定角色</h4>
          </div>
          <div class="modal-body">
            <table class="table table-bordered table-striped">
                <thead>
                    <th>角色名</th>
                    <th>组织机构</th>
                    <th>可见范围</th>
                    <th>是否启用</th>
                    <th>描述</th>
                </thead>
                <tbody>
                    <tr>
                        <td>超级管理员</td>
                        <td>天通物联网</td>
                        <td>全部可见</td>
                        <td>启用</td>
                        <td>拥有系统功能操作设置最高权限</td>
                    </tr>
                    <tr>
                        <td>GUEST用户</td>
                        <td>博仁集智</td>
                        <td>本部门及父部门可见</td>
                        <td>启用</td>
                        <td>GUEST用户</td>
                    </tr>
                    <tr>
                        <td>分公司用户操作权限</td>
                        <td>博仁集智</td>
                        <td>本部门及父部门可见</td>
                        <td>启用</td>
                        <td>拥有日常监控所需功能设置操作权限</td>
                    </tr>
                    <tr>
                        <td>通用用户</td>
                        <td>博仁集智</td>
                        <td>本部门及父部门可见</td>
                        <td>启用</td>
                        <td></td>
                    </tr>
                </tbody>
            </table>
          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-primary">保存</button>
            <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
          </div>
        </div>
      </div>
    </div> -->
    <!-- 5. 账户绑定权限模态框 -->
    <div class="modal fade" id="userRightModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
      <div class="modal-dialog" role="document">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
            <h4 class="modal-title" id="myModalLabel">账户绑定权限</h4>
          </div>
          <div class="modal-body">
            <div class="row">
                <!-- <h2>Checkable Tree</h2> -->
                <div class="col-sm-4">
                  <h2>角色列表</h2>
                  <div id="roleTree" class=""></div>
                  <!--<div class="form-group">
                    <label for="input-check-node" class="sr-only">Search Tree:</label>
                    <input type="input" class="form-control" id="input-check-node" placeholder="Identify node..." value="Parent 1">
                  </div>
                  <div class="checkbox">
                    <label>
                      <input type="checkbox" class="checkbox" id="chk-check-silent" value="false">
                      Silent (No events)
                    </label>
                  </div>
                   <div class="form-group row">
                    <div class="col-sm-6">
                      <button type="button" class="btn btn-success check-node" id="btn-check-node">Check Node</button>
                    </div>
                  </div>
                  <div class="form-group">
                    <button type="button" class="btn btn-danger check-node" id="btn-uncheck-node">Uncheck Node</button>
                  </div>
                  <div class="form-group">
                    <button type="button" class="btn btn-primary check-node" id="btn-toggle-checked">Toggle Node</button>
                  </div> -->
                  <hr>
                  <div class="form-group row">
                    <div class="col-sm-6">
                      <button type="button" class="btn btn-success" id="btn-check-all">全选</button>
                    </div>
                  </div>
                  <button type="button" class="btn btn-danger" id="btn-uncheck-all">全不选</button>
                </div>
                <div class="col-sm-4">
                  <h2>权限菜单</h2>
                  <div id="menuTree" class=""></div>
                </div>
                <div class="col-sm-4">
                  <h2>Events</h2>
                  <div id="checkable-output"></div>
                </div>
              </div>
          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-primary">保存</button>
            <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
          </div>
        </div>
      </div>
    </div>
    <!-- 6. 重置密码模态框 -->
    <!-- <div class="modal fade" id="resetPwdModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
      <div class="modal-dialog" role="document">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
            <h4 class="modal-title" id="myModalLabel">提示</h4>
          </div>
          <div class="modal-body">
            <span class="entypo-help yellow" style="font-size:50px;margin:0 50px;"></span>确定重置密码吗 ？
          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-primary">是</button>
            <button type="button" class="btn btn-default" data-dismiss="modal">否</button>
          </div>
        </div>
      </div>
    </div> -->

    <script type="text/javascript" src="assets/js/socket.io.js"></script>
    <script type="text/javascript" src="assets/js/ioconnect.js"></script>
    <script src="assets/js/md5.min.js"></script>
    <script type="text/javascript" src="assets/js/manage/commonSearch-jqgrid.js"></script>
    <script type="text/javascript" src="assets/js/manage/user-jqgrid.js"></script>
    <script type="text/javascript" src="assets/js/manage/commonPage-jqgrid.js"></script>

    <!-- MAIN EFFECT -->
    <script type="text/javascript" src="assets/js/preloader.js"></script>
    <script type="text/javascript" src="assets/js/bootstrap.js"></script>
    <script type="text/javascript" src="assets/js/app.js"></script>
    <script type="text/javascript" src="assets/js/load.js"></script>
    <script type="text/javascript" src="assets/js/main.js"></script>
          
    <!-- 树形列表 -->
    <script src="assets/js/tree/lib/jquery.cookie.js" type="text/javascript"></script>
    <script src="assets/js/tree/jquery.treeview.js" type="text/javascript"></script>

    <script type="text/javascript">
        $(function() {
            $("#browser, #browser2").treeview({
                animated: "fast",
                collapsed: false,
                unique: true,
                persist: "cookie",
                state: {
                    checked: true,
                    disabled: true,
                    expanded: true,
                    selected: true
                  },
                toggle: function() {
                    //window.console && console.log("%o was toggled", this);
                }
            });
        });
        $("#a").click(function(){
            $('#userRightModal').modal({backdrop: 'static', keyboard: false});
        })
        
    </script>
    <script src="assets/js/treeview/js/bootstrap-treeview.js"></script>
    <script type="text/javascript">

        $(function() {
            var right = [];//权限：数组对象
            var role = null;//角色：0/1/2
            right = [
                        {name: "all", edit: 0, select: 0},
                        {name: "device", edit: 0, select: 0},
                        {name: "log", edit: 0, select: 0},
                        {name: "user", edit: 0, select: 0},
                        {name: "role", edit: 0, select: 0},
                        {name: "logfile", edit: 0, select: 0},
                        {name: "warn_report", edit: 0, select: 0},
                        {name: "warn_config", edit: 0, select: 0}
                    ];
            
            // 选中父节点时，选中所有子节点
            function getChildNodeIdArr(node) {   
                var ts = [];
                if (node.nodes) {    
                    for (x in node.nodes) {     
                        ts.push(node.nodes[x].nodeId);     
                        if (node.nodes[x].nodes) {      
                            var getNodeDieDai = getChildNodeIdArr(node.nodes[x]);      
                            for (j in getNodeDieDai) {       
                                    ts.push(getNodeDieDai[j]);     
                            }     
                        }    
                    }   
                } else {    
                    ts.push(node.nodeId);   
                }   
                return ts;  
            }   
            // 选中所有子节点时，选中父节点 取消子节点时取消父节点
            function setParentNodeCheck(node) {   
                var parentNode = $("#menuTree").treeview("getNode", node.parentId);   
                if (parentNode.nodes) {    
                    var checkedCount = 0;    
                    for (x in parentNode.nodes) {     
                        if (parentNode.nodes[x].state.checked) {      
                            checkedCount ++;     
                        } else {      
                            break;     
                        }  
                    }    
                    if (checkedCount == parentNode.nodes.length) {  //如果子节点全部被选 父全选
                        $("#menuTree").treeview("checkNode", parentNode.nodeId);
                        setParentNodeCheck(parentNode);    
                    }else {   //如果子节点未全部被选 父未全选
                        $('#menuTree').treeview('uncheckNode', parentNode.nodeId); 
                        setParentNodeCheck(parentNode);        
                    }   
                }  
            }     
            // 取消父节点时 取消所有子节点
            function setChildNodeUncheck(node) { 
                if (node.nodes) {   
                    var ts = [];    //当前节点子集中未被选中的集合 
                    for (x in node.nodes) { 
                        if (!node.nodes[x].state.checked) {  
                            ts.push(node.nodes[x].nodeId);  
                        } 
    
                    }   
                }
                return ts;  
            }
            // 获得所有节点
            function setTheRight(role,node){
                // var theRight = [];

                if(/(_edit$)|(_select$)/.test(node.href)){
                    // console.log("哈哈哈");

                }
            }
            //权限列表 数据
            var menuData = [
              {
                text: '所有权限',
                href: '#all',
                tags: ['7'], 
                nodes: [
                  {
                    text: '设备管理',
                    href: '#device',
                    tags: ['2'],
                    nodes: [
                      {
                        text: '查看',
                        href: '#device_select',
                        tags: ['0']
                      },
                      {
                        text: '编辑',
                        href: '#device_edit',
                        tags: ['0']
                      }
                    ]
                  },
                  {
                    text: '历史数据',
                    href: '#log',
                    tags: ['1'],
                    nodes: [
                      {
                        text: '查看',
                        href: '#log_select',
                        tags: ['0']
                      }
                    ]
                  },
                  {
                    text: '用户管理',
                    href: '#user',
                    tags: ['2'],
                    nodes: [
                      {
                        text: '查看',
                        href: '#user_select',
                        tags: ['0']
                      },
                      {
                        text: '编辑',
                        href: '#user_edit',
                        tags: ['0']
                      }
                    ]
                  },
                  {
                    text: '权限管理',
                    href: '#role',
                    tags: ['2'],
                    nodes: [
                      {
                        text: '查看',
                        href: '#role_select',
                        tags: ['0']
                      },
                      {
                        text: '编辑',
                        href: '#role_edit',
                        tags: ['0']
                      }
                    ]
                  },
                  {
                    text: '登录日志',
                    href: '#logfile',
                    tags: ['1'],
                    nodes: [
                      {
                        text: '查看',
                        href: '#logfile_select',
                        tags: ['0']
                      }
                    ]
                  },
                  {
                    text: '报警信息',
                    href: '#warn_report',
                    tags: ['1'],
                    nodes: [
                      {
                        text: '查看',
                        href: '#warn_report_select',
                        tags: ['0']
                      }
                    ]
                  },
                  {
                    text: '报警管理',
                    href: '#warn_config',
                    tags: ['2'],
                    nodes: [
                      {
                        text: '查看',
                        href: '#warn_config_select',
                        tags: ['0']
                      },
                      {
                        text: '编辑',
                        href: '#warn_onfig_edit',
                        tags: ['0']
                      }
                    ]
                  },
                ]
              }
            ];
            //角色列表 数据
            var roleData = [
              {
                text: '超级管理员',
                tags: ['0'],
              },
              {
                text: '管理员',
                tags: ['0']
              },
              {
                text: '普通用户',
                tags: ['0']
              }
            ];
            //角色列表 设置
            $('#roleTree').treeview({
                data: roleData,
                // showIcon: false,
                // showCheckbox: true,
                onNodeSelected: function(event,node){
                    console.log(node.text + " is select");
                    //nodeId: 0 超级 1管理 2普通
                    role = node.nodeId;
                    console.log("role is "+role);
                    if(node.text == "超级管理员"){
                        $menuTree.treeview('checkAll', { silent: $('#chk-check-silent').is(':checked') });
                    }
                },
                onNodeUnselected: function(event,node){
                    console.log(node.text + " is unselected");
                    role = null;
                    console.log("role is "+role);
                    $menuTree.treeview('uncheckAll', { silent: $('#chk-check-silent').is(':checked') });
                }
            });

            //权限列表 设置
            var $menuTree = $('#menuTree').treeview({
              data: menuData,
              showIcon: false,
              showCheckbox: true,
              collapsed: true,
              // expanded: true,
              onNodeChecked: function(event, node) {
                
                

                var fixId = node.parentId 
                var fixSelectable = node.selectable   
                var fixText = node.text   
                console.log( '@@::' + fixId)
                console.log( '@@::' + node.selectable)
                console.log( '@@::' + node.text)

                switch(fixId)
                {
                    case 1:
                        fixRight(1)
                    break;
                    case 4:
                        fixRight(4)
                    break;
                    case 6:
                        fixRight(6)
                    break;
                    case 9:
                        fixRight(9)
                    break;
                }
                console.log(node);

                console.log(right)

                function fixRight(num){
                    if (fixText == '查看' ) {
                        if (fixSelectable==true) {
                            for(var all in right[num]) {
                                right[num].select = 1
                            }
                        }else{
                            for(var all in right[num]) {
                                right[num].select = 0
                            }
                        }
                    }
                    if (fixText == '编辑' ) {
                        if (fixSelectable==true) {
                            for(var all in right[num]) {
                                right[num].edit = 1
                            }
                        }else{
                            for(var all in right[num]) {
                                right[num].edit = 0
                            }
                        }
                    }
                }

                // if(node.href == "#all"){
                //     right[0] = {name: "all", edit: 1, select: 1};
                //     console.log(right);
                // }
                // console.log(node.href.replace("#",""));
                console.log(role);
                setTheRight(null,node);
                var selectNodes = getChildNodeIdArr(node); //获取所有子节点
                console.log("selectNodes "+ selectNodes);
                if (selectNodes) { //子节点不为空，则选中所有子节点       
                    $('#menuTree').treeview('checkNode', [selectNodes, { silent: true }]);    
                }     
                var parentNode = $("#menuTree").treeview("getNode", node.parentId);      
                setParentNodeCheck(node);
                $('#checkable-output').html('');
                 $('#checkable-output').prepend('<p>' + node.text + ' was checked</p>');
                
              },
              onNodeUnchecked: function (event, node) {
                // 取消父节点 子节点取消
                var selectNodes = setChildNodeUncheck(node); //获取未被选中的子节点 
                var childNodes = getChildNodeIdArr(node);    //获取所有子节点 
                if (selectNodes && selectNodes.length==0) { //有子节点且未被选中的子节点数目为0，则取消选中所有子节点   
                  console.log("反选");   
                  $('#menuTree').treeview('uncheckNode', [childNodes, { silent: true }]);      
                }  
                // 取消节点 父节点取消
                var parentNode = $("#menuTree").treeview("getNode", node.parentId);  //获取父节点
                var selectNodes = getChildNodeIdArr(node);     
                setParentNodeCheck(node); 
                $('#checkable-output').prepend('<p>' + node.text + ' was unchecked</p>');
              }
            });
            //展开 权限菜单
            $('#menuTree').treeview('expandAll', { levels: 2, silent: true });

            var findCheckableNodess = function() {
              return $menuTree.treeview('search', [ $('#input-check-node').val(), { ignoreCase: false, exactMatch: false } ]);
            };
            var checkableNodes = findCheckableNodess();

            // Check/uncheck/toggle nodes
            $('#input-check-node').on('keyup', function (e) {
              checkableNodes = findCheckableNodess();
              $('.check-node').prop('disabled', !(checkableNodes.length >= 1));
            });

            $('#btn-check-node.check-node').on('click', function (e) {
              $menuTree.treeview('checkNode', [ checkableNodes, { silent: $('#chk-check-silent').is(':checked') }]);
            });

            $('#btn-uncheck-node.check-node').on('click', function (e) {
              $menuTree.treeview('uncheckNode', [ checkableNodes, { silent: $('#chk-check-silent').is(':checked') }]);
            });

            $('#btn-toggle-checked.check-node').on('click', function (e) {
              $menuTree.treeview('toggleNodeChecked', [ checkableNodes, { silent: $('#chk-check-silent').is(':checked') }]);
            });

            // Check/uncheck all
            $('#btn-check-all').on('click', function (e) {
              $menuTree.treeview('checkAll', { silent: $('#chk-check-silent').is(':checked') });
            });

            $('#btn-uncheck-all').on('click', function (e) {
              $menuTree.treeview('uncheckAll', { silent: $('#chk-check-silent').is(':checked') });
            });

            console.log(right);
        });
    </script>
</body>

</html>
